//
//  QDDoctorCell.m
//  simulateQuickDoctor
//
//  Created by 姚华杰 on 2017/3/23.
//  Copyright © 2017年 PipiXia. All rights reserved.
//

#import "QDDoctorCell.h"
#import <UIImageView+WebCache.h>
@interface QDDoctorCell ()

//头像图片
@property (weak, nonatomic) IBOutlet UIImageView *imgView;

//名字
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

//医生类别
@property (weak, nonatomic) IBOutlet UILabel *sortLabel;

//地址
@property (weak, nonatomic) IBOutlet UILabel *hospitalNameLabel;

//预约数
@property (weak, nonatomic) IBOutlet UILabel *bespeakNUmLabel;

//鲜花数
@property (weak, nonatomic) IBOutlet UILabel *flowersNumLabel;

//锦旗数
@property (weak, nonatomic) IBOutlet UILabel *jinqiNumLabel;

@end

@implementation QDDoctorCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.accessoryView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"position-right"]];
}

-(void)setModel:(QDDAModel *)model{
    
    _model = model;
    
    
    [_imgView sd_setImageWithURL:[NSURL URLWithString:model.doctor_portrait] placeholderImage:[UIImage imageNamed:@"patient_defaultphoto_male"]];
    
    [self clipIcon:_imgView];
    
    _nameLabel.text = model.doctor_name;
    
    _sortLabel.text = model.doctor_title_name;
    
    _hospitalNameLabel.text = model.doctor_hospital_name;
    
    _bespeakNUmLabel.text = @(model.operation_count).description;
    
    _flowersNumLabel.text = @(model.flower).description;
    
    _jinqiNumLabel.text = @(model.banner).description;
    
    

    
}



- (void)clipIcon:(UIImageView*)iconView{
    
    //加载图片
    UIImage *image = iconView.image;
    
    //获取图片尺寸
    CGSize size = image.size;
    
    //开启位图上下文
    UIGraphicsBeginImageContextWithOptions(size, NO, 0);
    
    //创建圆形路径
    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
    
    //设置为裁剪区域
    [path addClip];
    
    //绘制图片
    [image drawAtPoint:CGPointZero];
    
    //获取裁剪后的图片
    iconView.image = UIGraphicsGetImageFromCurrentImageContext();
    
    //关闭上下文
    UIGraphicsEndImageContext();
    
}

@end
